package com.sirun.ble.net;

import android.content.Context;

import com.sirun.ble.net.AwNetUtil.OnRequestCallBack;
import com.sirun.ble.utils.AwLog;

import static com.sirun.ble.constants.BleConfig.BleSdkTag;

import org.json.JSONObject;

import java.util.HashMap;

/**
 * @author : hzw
 */
public class BleNetRequestUtil {

    private static final String url_allRentalCarList = "weima-service/des/info/";
    private static final String url_rentalCar = "weima-service/des/tenant";
    private static final String url_returnCar = "weima-service/des/refund";
    private static final String url_adminUseCar = "weima-service/des/admin/";
    private static final String url_adminReturnCar = "weima-service/des/back/";

    public static void getAllRentalCarList(Context context, String vin, OnRequestCallBack callBack) {
        AwLog.d(BleSdkTag, "BleNetRequestUtil getAllRentalCarList");

        AwNetUtil.getInstance().get(context,url_allRentalCarList + vin, callBack);
    }

    public static void rentalCar(Context context, String createTime, String expireTime, String vin, OnRequestCallBack callBack) {
        AwLog.d(BleSdkTag, "BleNetRequestUtil rental car");
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("createTime", createTime);
        hashMap.put("expireTime", expireTime);
        hashMap.put("vin", vin);
        String json = String.valueOf(new JSONObject(hashMap));
        AwNetUtil.getInstance().postJson(context,url_rentalCar, json, callBack);
    }

    public static void returnCar(Context context,  String vin, OnRequestCallBack callBack) {
        AwLog.d(BleSdkTag, "BleNetRequestUtil return car");
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("vin", vin);
        String json = String.valueOf(new JSONObject(hashMap));
        AwNetUtil.getInstance().postJson(context,url_returnCar, json, callBack);
    }


    public static void adminUseCar(Context context, String vin, OnRequestCallBack callBack) {
        AwLog.d(BleSdkTag, "BleNetRequestUtil adminUseCar");

        AwNetUtil.getInstance().get(context, url_adminUseCar + vin, callBack);
    }

    public static void adminReturnCar(Context context, String vin, OnRequestCallBack callBack) {
        AwLog.d(BleSdkTag, "BleNetRequestUtil adminReturnCar");

        AwNetUtil.getInstance().get(context, url_adminReturnCar + vin, callBack);
    }
}
